﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using DAL;
using BLL;
using System.Text; 
namespace SearchEngine.CMS.Client
{
    public partial class UcMenu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String QueryString = "";
            StringBuilder sb = new StringBuilder();
            try{
                if (!Page.IsPostBack)
                {

                    //thuc hien lay query string 
                    if (Request.QueryString["Type"].ToString() != null)
                    {
                        QueryString = Request.QueryString["Type"].ToString();
                    }
                    DataTable dt = new DataTable();
                    DataColumn[] cl = new DataColumn[] { new DataColumn("MaDichVu"), new DataColumn("TenDichVu") };
                    dt.Columns.AddRange(cl);
                    dt = DICHVUBUS.GetALL();
                    DataRow dr1 = dt.NewRow();
                    dr1["MaDichVu"] = "19";
                    dr1["TenDichVu"] = "Tất Cả";
                    dt.Rows.InsertAt(dr1, 0);
                    if (dt.Rows.Count > 0)
                    {
                        sb.Append("<ul>");
                        int i = 1;
                        foreach (DataRow dr in dt.Rows)
                        {

                            if (dr["MaDichVu"].ToString().Equals(QueryString))
                            {

                                sb.Append(" <li><a class='current' href='Search.aspx?Type=" + dr["MaDichVu"] + "'   id='tabs" + i + "' >" + dr["TenDichVu"].ToString() + "</a></li>");
                            }
                            else
                            {
                                sb.Append(" <li><a id='tabs" + i + "' href='Search.aspx?Type=" + dr["MaDichVu"] + "'>" + dr["TenDichVu"].ToString() + "<!--[if IE 7]><!--></a><!--<![endif]--></li>");
                            }
                            i++;
                        }

                        sb.Append("</ul>");
                    }
                }
                }
                catch{return;}
                this.lbmenu.Text = sb.ToString();
            }
        }
    
}